<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>家政管理系统-V6.8</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/static/branch_oa/css/font.css">
        <link rel="stylesheet" href="${pageContext.request.contextPath}/static/branch_oa/css/xadmin.css">
        <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/static/branch_oa/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/static/branch_oa/js/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body style="background: #fff;">
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <input type="hidden" name="buid" value="${jsbuid}">
                    <input type="hidden" name="yworkinghours" value="${cardCZ.yworkinghours}">
                    <input type="hidden" name="nworkinghours" value="${cardCZ.nworkinghours}">
                    <input type="hidden" name="ybalance" value="${cardCZ.ybalance}">
                    <input type="hidden" name="nbalance" value="${cardCZ.nbalance}">
                    <input type="hidden" name="id" value="${cardCZ.id}">


                    <div class="layui-form-item" style="display: inline-block;">
                        <label  class="layui-form-label">
                            家政卡类型：
                        </label>
                        <div class="layui-input-inline">
                            <select  name="cardtype" class="valid" >
                                <c:if test="${cardCZ==null}">
                                    <option value="${cardCZ.cardtype}" selected>请选择卡类型</option>
                                    <option value="0" >小时卡</option>
                                    <option value="1" >现金卡</option>
                                </c:if>
                                <c:if test="${cardCZ.cardtype==0}">
                                    <option value="0" selected>小时卡</option>
                                    <option value="1" >现金卡</option>
                                </c:if>
                                <c:if test="${cardCZ.cardtype==1}">
                                    <option value="1" selected>现金卡</option>
                                    <option value="0" >小时卡</option>
                                </c:if>

                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: inline-block;">
                        <label for="cardid" class="layui-form-label">
                            家政卡号：
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="cardid" name="cardid" required="" lay-verify="money" value="${cardCZ.cardid}"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                  <div class="layui-form-item" style="display: inline-block;">
                      <label for="money" class="layui-form-label">
                          卡面额：
                      </label>
                      <div class="layui-input-inline">
                          <div class="layui-input-inline">
                              <select  name="cdid" class="valid" id="money" >
                                  <c:if test="${cardCZ==null}">
                                      <option value="" selected>请选择充值卡面额</option>
                                      <c:forEach var="denominations" items="${denominationList}">
                                          <option value="${denominations.id}" >${denominations.denomination}</option>
                                      </c:forEach>
                                  </c:if>
                                 <c:if test="${cardCZ!=null}">
                                     <c:forEach var="denominations" items="${denominationList}">
                                         <c:if test="${cardCZ.cdid == denominations.id}">
                                             <option value="${cardCZ.cdid}" selected>${cardCZ.cardDenomination.denomination}</option>
                                         </c:if>
                                         <c:if test="${cardCZ.cdid != denominations.id}">
                                             <option value="${denominations.id}" >${denominations.denomination}</option>
                                         </c:if>

                                     </c:forEach>
                                  </c:if>

                              </select>
                          </div>

                      </div>
                  </div>

                    <div class="layui-form-item" style="display: inline-block;">
                        <label for="time" class="layui-form-label">
                            有效期至：
                        </label>
                        <div class="layui-input-inline">
                            <div class="layui-input-inline">
                                <input class="layui-input"  autocomplete="off" placeholder="" name="period" id="time"
                                       value='<fmt:formatDate value="${cardCZ.period}" pattern="yyyy-MM-dd" />'
                                >
                            </div>

                        </div>
                    </div>

                  <div class="layui-form-item" style="display: inline-block;">
                      <label for="ytime" class="layui-form-label">
                          充值工时 ：
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="ytime" name="rechargehours" required="" lay-verify="ytime"
                          autocomplete="off" class="layui-input">
                      </div>
                  </div>
                    <div class="layui-form-item" style="display: inline-block;">
                        <label for="price" class="layui-form-label">
                            钟点工价 ：
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="price" name="hourlyrate" required="" lay-verify="price"  value="${cardCZ.hourlyrate}"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item" style="display: inline-block;">
                        <label for="stime" class="layui-form-label">
                            联系方式 ：
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="tel" name="tel" required="" lay-verify="stime" value="${cardCZ.tel}"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>

                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>

                      <button  class="layui-btn" lay-filter="invest" lay-submit="">
                          充值
                      </button>

                      <button  class="layui-btn" lay-filter="select"  lay-submit="">
                          查询
                      </button>
                  </div>
              </form>
            </div>
        </div>
        <script type="text/javascript" src="${pageContext.request.contextPath}/static/branch_oa/js/xcity.js"></script>


        <%--系统script--%>
        <script>

        layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

            //执行一个laydate实例
            laydate.render({
                elem: '#time' //指定元素
            });

      });
       
        layui.use(['form', 'layer'],

            
            function() {
                $ = layui.jquery;
                var form = layui.form,
                    layer = layui.layer;

                //监听提交(去查询当前选择的会员卡类型，和会员卡号，验证数据)
                form.on('submit(select)',

                function(data) {
                    $.ajax({
                        url: "${pageContext.request.contextPath}/ocard/findCardByCardId",
                        data:data.field,
                        success: function (res) {
                            if(res){
                                layer.alert("查询成功，请自行核对联系方式与充值客户是否匹配", {
                                        icon: 6
                                    },
                                    function() {

                                        // 可以对父窗口进行刷新
                                        xadmin.father_reload();
                                    });
                            }else{
                                layer.alert("卡类型与卡号不匹配或卡号不存在,请核实后重新输入", {
                                    icon: 5
                                }, function() {


                                    // 可以对父窗口进行刷新
                                    xadmin.father_reload();
                                });
                            }
                        }
                    })
                    return false;
                });

                form.on('submit(invest)',
                    function(data) {
                        $.ajax({
                            url: "${pageContext.request.contextPath}/ocard/rechargeCard",
                            data:data.field,
                            success: function (res) {
                                if(res){
                                    layer.alert("充值成功", {
                                            icon: 6
                                        },
                                        function() {

                                            // 可以对父窗口进行刷新
                                            xadmin.father_reload();
                                        });
                                }else{
                                    layer.alert("充值失败", {
                                        icon: 5
                                    }, function() {
                                        // 可以对父窗口进行刷新
                                        xadmin.father_reload();
                                    });
                                }
                            }
                        });
                        return false;
                    });

            });</script>
        <script>var _hmt = _hmt || []; (function() {
                var hm = document.createElement("script");
                hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();</script>
    </body>

</html>
